package Lee_code;

public class Lee_198 {
    int len;
    int max=0;
    public int rob(int[] nums) {
        len = nums.length;
        if(len==0) return 0;
        dfs(0, -2, nums);

        return max;
    }

    private void dfs(int cur_sum, int index, int[] nums) {
        if(index>=len) return;

        if(index!=-1)
            cur_sum = cur_sum + nums[index];

        max=Math.max(max,cur_sum);
        dfs(cur_sum, index+2, nums);
        dfs(cur_sum, index+3, nums);
    }
}
